<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ pdf_title }}</title>
    <link rel="icon" href="/static/icons/pdf.svg" type="image/svg+xml">
    <script>
        // 确保PDF.js可以处理包含特殊字符的URL
        document.addEventListener('DOMContentLoaded', function () {
            const iframe = document.querySelector('iframe');
            const pdfUrl = "{{ pdf_url }}";
            console.log("PDF URL:", pdfUrl);

            // 使用encodeURIComponent确保URL正确编码
            const encodedUrl = encodeURIComponent(pdfUrl);
            console.log("Encoded URL:", encodedUrl);

            // 设置iframe的src
            iframe.src = `/static/pdfjs/web/viewer.html?file=${encodedUrl}`;
        });
    </script>
</head>

<body style="margin:0; padding:0; height:100vh;">
    <iframe style="width:100%; height:100%; border:none;"></iframe>
</body>

</html>